package oj;

import java.util.Stack;

/**
 * @author 郝文雪
 * @date 2022/8/25 16:49
 * @Description Test
 */
public class LC173 {
    Stack<TreeNode> stack;
    TreeNode cur;
    public LC173(TreeNode root) {
        stack=new Stack<>();
        cur=root;
    }

    public int next() {
        while(cur!=null){
            stack.push(cur);
            cur=cur.left;
        }
        cur=stack.pop();
        int ret=cur.val;
        cur=cur.right;
        return ret;
    }

    public boolean hasNext() {
        return cur!=null || !stack.isEmpty();
    }
}
